package br.com.poc.pitagorasnumero.type;

/**
 * The Enum TablePitagoricaDomain.
 * 
 * @author irlan.gomes
 * 
 */
public enum TablePitagoricaType {

	/** The value 1. */
	VALUE_1(1, "A", "J", "S"),

	/** The value 2. */
	VALUE_2(2, "B", "K", "T"),

	/** The value 3. */
	VALUE_3(3, "C", "L", "U"),

	/** The value 4. */
	VALUE_4(4, "D", "M", "V"),

	/** The value 5. */
	VALUE_5(5, "E", "N", "W"),

	/** The value 6. */
	VALUE_6(6, "F", "O", "X"),

	/** The value 7. */
	VALUE_7(7, "G", "P", "Y"),

	/** The value 8. */
	VALUE_8(8, "H", "Q", "Z"),

	/** The value 9. */
	VALUE_9(9, "I", "R", "$"),

	/** The error. */
	ERROR(0, "$", "$", "$");

	/** The value letter. */
	private int valueLetter;

	/** The letter1. */
	private String letter1;

	/** The letter2. */
	private String letter2;

	/** The letter3. */
	private String letter3;

	/**
	 * Instantiates a new table pitagorica domain.
	 * 
	 * @param valueLetter
	 *            the value letter
	 * @param letter1
	 *            the letter1
	 * @param letter2
	 *            the letter2
	 * @param letter3
	 *            the letter3
	 */
	private TablePitagoricaType(final int valueLetter, final String letter1,
			final String letter2, final String letter3) {
		this.valueLetter = valueLetter;
		this.letter1 = letter1;
		this.letter2 = letter2;
		this.letter3 = letter3;
	}

	/**
	 * Gets the value letter.
	 * 
	 * @param letter
	 *            the letter
	 * @return the value letter
	 */
	public static TablePitagoricaType getValueLetter(final String letter) {
		TablePitagoricaType result = TablePitagoricaType.ERROR;

		for (final TablePitagoricaType domain : TablePitagoricaType
				.values()) {
			if (domain.letter1.equals(letter) || domain.letter2.equals(letter)
					|| domain.letter3.equals(letter)) {

				result = domain;
			}
		}

		return result;
	}

	/**
	 * Gets the value number.
	 *
	 * @param number the number
	 * @return the value number
	 */
	public static TablePitagoricaType getValueNumber(final int number) {

		TablePitagoricaType result = TablePitagoricaType.ERROR;

		for (final TablePitagoricaType domain : TablePitagoricaType
				.values()) {
			if (domain.valueLetter == number) {

				result = domain;
			}
		}

		return result;
	}

	/**
	 * Gets the value letter.
	 * 
	 * @return the value letter
	 */
	public int getValueLetter() {
		return valueLetter;
	}

	/**
	 * Gets the letter1.
	 * 
	 * @return the letter1
	 */
	public String getLetter1() {
		return letter1;
	}

	/**
	 * Gets the letter2.
	 * 
	 * @return the letter2
	 */
	public String getLetter2() {
		return letter2;
	}

	/**
	 * Gets the letter3.
	 * 
	 * @return the letter3
	 */
	public String getLetter3() {
		return letter3;
	}

}
